import Vue from 'vue'
import VueRouter from 'vue-router'
import Film from '@/views/Film'
import Cinema from '@/views/Cinema'
import Center from '@/views/Center'
import Nowplaying from '@/views/Film/Nowplaying'
import Comingsoon from '@/views/Film/Comingsoon'
import Detail from '@/views/Detail'
import Login from '@/views/Login'
import Ticket from '@/views/Detail/Ticket'
import Ticketpage from '@/views/Detail/Ticketpage'
import Schedule from '@/views/Schedule'

// import Home from '../views/Home.vue'

Vue.use(VueRouter)

const auth = {
  isLogin () {
    return true
  }
}

const routes = [
  {
    path: '/film',
    name: 'film',
    component: Film,
    children: [
      {
        path: 'nowplaying',
        component: Nowplaying
      },
      {
        path: 'comingsoon',
        component: Comingsoon
      },
      {
        path: '',
        name: 'nowplaying',
        redirect: '/film/nowplaying'
      }
    ]
  },
  {
    path: '/cinema',
    name: 'cinema',
    component: Cinema
  },
  {
    path: '/center',
    name: 'center',
    component: Center
  },
  {
    path: '/detail/:id',
    name: 'detail',
    component: Detail
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '/ticket/:id',
    name: 'ticket',
    component: Ticket
  },
  {
    path: '/ticketpage/:cid',
    name: 'ticketpage',
    component: Ticketpage
  },
  {
    path: '/schedule/:id',
    name: 'schedule',
    component: Schedule
  },
  {
    path: '*',
    redirect: '/film'
  }

]

const router = new VueRouter({
  // mode: 'history',
  base: process.env.BASE_URL,
  routes
})

// router.beforeEach((to,from,next) => {
//   if(to.path==='/center'){
//     console.log("check")
//     if(auth.isLogin()){
//       console.log("验证成功")
//       next()
//     }else{
//       next("/login")
//     }
//   }else{
//     next()
//   }
// })

export default router
